package
{
	
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import flash.display.*;
	import Popup;
	
	public class ScreenLogon extends Screen
	{
		
		private var skin:mcScreenLogonSkin;
		private var popupMessage:Popup;
		public static const ACCESS_CODE:String = "123456";
		public static const DEFAULT_AC:String = "Please enter your access code...";
		public static const INVALID:String = "Invalid Code!";
		public static const XINS_TWITTER:String = "http://twitter.com/XinOP13";
		
		public function ScreenLogon()
		{
			
			super();
			
		}
		
		override public function init():void
		{
			
			destroy();
			skin = new mcScreenLogonSkin();
			addChild(skin);
			skin.strAC_txt.text = DEFAULT_AC;
			skin.btnTwitterXin.addEventListener(MouseEvent.CLICK, navigateXinTwitter);
			skin.btnPlay3.addEventListener(MouseEvent.CLICK, btnPlay3);
			popupMessage.destroy();
		}
		
		private function navigateXinTwitter(e:MouseEvent):void
		{
			
			navigateToURL(new URLRequest(XINS_TWITTER));
			
		}
		
		private function btnPlay3(e:MouseEvent):void
		{
			
			
			var i:int = skin.strAC_txt.text.length;
			
				if (i > 0 && skin.strAC_txt.text == ACCESS_CODE)
				{
					
					trace("correct code");
					gotoAndStop("CharCreation");
					
				} else {
					
					trace("invalid code");
					popupMessage = new Popup();
					popupMessage.strMsgT1 = INVALID;
					popupMessage.intDuration = 4;
					popupMessage.init();
				
				}
		}
		
		override public function destroy():void
		{
			
			trace("kill.destroy");
			removeChild(skin);
			skin = null;
			removeChild(popupMessage);
			popupMessage = null;
			
		}
	}
}